package butines.game.lastcolony.screen;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;

import butines.core.GameImage;
import butines.core.gui.GUIImage;
import butines.core.gui.GUILabel;
import butines.core.gui.MouseEvent;
import butines.core.gui.style.Text;
import butines.core.gui.style.TextShadow;
import butines.game.lastcolony.LastColony;

public class MissionScreen extends AbstractScreen {

	private GameImage background;
	private GameImage buttons;
	
	private GUIImage entreMission;
	private GUIImage exitMission;
	private GUILabel missonBriefing;
	
	public MissionScreen(LastColony game) {
		super(game);
		
		loadImage();

		createGui();
	}
	
	private void loadImage() {
	    background = new GameImage("images/missionscreen.png");
	    buttons = new GameImage("images/buttons.png");
	}
	
	private void createGui() {
	    
	    Text text = new Text(new Font("Courier New", Font.PLAIN, 13));
        text.setColor(new Color(130, 150, 162));
        
        TextShadow textShadow = new TextShadow();
        textShadow.setText(text.copy());
        textShadow.getText().setColor(Color.BLACK);
        textShadow.add(1, 1);
	    
	    exitMission = new GUIImage(380, 79);
        exitMission.setImage(buttons, 0, 76, 98, 68);
        exitMission.setImageActived(buttons, 103, 76, 98, 68);
        exitMission.setGuiListener(this);

        entreMission = new GUIImage(6, 79);
        entreMission.setImage(buttons, 0, 0, 246, 68);
        entreMission.setImageActived(buttons, 251, 0, 246, 68);
        entreMission.setGuiListener(this);
            
        missonBriefing = new GUILabel(30, 170, "");
        missonBriefing.setText(text);
        missonBriefing.setTextShadow(textShadow);
	    
	    painel.add(entreMission);
        painel.add(exitMission);
        painel.add(missonBriefing);
	}
	
	public void setBriefing(String text) {
		missonBriefing.setLabel(text);
	}

    @Override
    public void render(Graphics2D g2d) {
        background.draw(g2d, 0, 0);
    }

    @Override
    public void onClick(MouseEvent e) {
        if (e.getSource() == exitMission) {
            lastColony.getSinglePlayer().exit();
        }
        if (e.getSource() == entreMission) {
            lastColony.getSinglePlayer().play();
        }

    }
    
    
	
}